/*
 * ExceptionPanel.java
 * 
 * Created on 23.11.2007, 20:17:04
 * 
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package cz.possoft.client.gui.panel.nastavenispodnipanel.components;

import java.awt.Color;
import javax.swing.JLabel;
import javax.swing.JPanel;
import layout.TableLayout;

/**
 *
 * @author mara
 */
public class ExceptionPanel extends JPanel {

    private JLabel exceptionLabel1;
    private JLabel exceptionLabel2;            
    
    double nastaveniSize[][] = {{189}, {22,22}};
    
    public ExceptionPanel(String s) {
        super();        
        setLayout(new TableLayout(nastaveniSize));
        exceptionLabel1 = new JLabel();
        exceptionLabel2 = new JLabel();
        exceptionLabel1.setForeground(Color.red);
        exceptionLabel2.setForeground(Color.red);
        add(exceptionLabel1,"0,0");
        add(exceptionLabel2,"0,1");
        setText(s);
    }        
    
    public void setText(String text) {        
        if (text.indexOf("|") == -1) {
            exceptionLabel1.setText(text);
            exceptionLabel2.setText("");
        }
        else {
            exceptionLabel1.setText(text.substring(0, text.indexOf("|")));
            exceptionLabel2.setText(text.substring(text.indexOf("|")+1));
        }
    }

}
